import { listIntroductionDict } from '@/apis'
import type { LabelValueState } from '@/types/global'
import { ref } from 'vue'

/** 公司简介模块字典 */
export function useIntroductionDict(options?: { onSuccess?: () => void }) {
  const loading = ref(false)
  const introductionDicList = ref<LabelValueState[]>([])

  const getIntroductionDicList = async (id: number) => {
    try {
      loading.value = true
      const res = await listIntroductionDict({companyId: id })
      introductionDicList.value = res.data
      options?.onSuccess && options.onSuccess()
    } finally {
      loading.value = false
    }
  }
  return { introductionDicList, getIntroductionDicList, loading }
}